<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;
use think\Cache;

class Overview extends Base
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $count['c'] = model('customer')->count();
        $count['o'] = model('order')->count();
        $count['yc'] = model('customer')->whereTime('create_time', 'yesterday')->count();
        $count['yo'] = model('order')->whereTime('create_time', 'yesterday')->count();
        //p($count);die;
        $this->assign('count',$count);
/*        $date = db('date')
            ->column('date','id');*/
        $this->assign('date',$this->getDate());
        return view();
    }

    /**
     * @return array|mixed
     * 获取活动日期
     */
    private function getDate()
    {
        $project_date = Cache::get('project_date');
        if (!$project_date) {
            $project_date = db('date')
                ->column('date','id');
            Cache::set('project_date',$project_date);
        }
        return $project_date;
    }
}
